home *** CD-ROM | disk | FTP | other *** search
/ PCNet 2006 April / PCnet 2006-06.4.iso / shareware / nmsetup.exe / WebServer / web / details.php < prev    next >
Encoding:
PHP Script  |  2006-05-01  |  5.4 KB  |  135 lines

  1. <?php
  2. ////////////////////////////////////////////////////////////////////////////////
  3. // <!--Copyright (c) 2005 Pure Networks Inc.  All rights reserved.-->
  4. ////////////////////////////////////////////////////////////////////////////////
  5. //
  6. // Build: 3.0.6121.0 (Stable)
  7. // $Revision: #1 $
  8. //
  9. ?>
  10. <table cellspacing="0" cellpadding="0" border="0">
  11.     <tr>
  12.         <td>
  13.             <div class="DetailsPanel">
  14. <?php
  15. $sPath  = $sFullFilePath;
  16. $iDetailsCount = 0;
  17.  
  18.     // Let's get the file's extension so we know which block of code to exexute for the details
  19.     $sExtension = substr(strrchr($sPath, "."), 1);
  20.     switch (strtolower($sExtension))
  21.     {
  22.         case "jpeg":
  23.         case "jpg":
  24.         case "jpe":
  25.             ///////////////////////////////////////////////////
  26.             // Let's find if there is EXIF data and use it if so.
  27.             ///////////////////////////////////////////////////
  28.             $arImgHeaders = exif_read_data($sPath, 'IFD0');
  29.             $arImgHeaders = exif_read_data($sPath, 0, true);
  30.             ///////////////////////////////////////////////////
  31.             // Let's print any header data that we can get a hold of
  32.             // Any that do not exist are not returned and thus not printed
  33.             ///////////////////////////////////////////////////
  34.             imgHeaderDataForDisplay("Camera", imgHeaderData("IFD0", "Model", $arImgHeaders), NULL);
  35.             $strDate = imgHeaderData("EXIF", "DateTimeDigitized", $arImgHeaders);
  36.             if ($strDate != "")
  37.             {
  38.                 // replace the :'s between date fields with -'s
  39.                 $strDate = sprintf("%04d-%02d-%02d %02d:%02d:%02d", substr($strDate,0,4), substr($strDate,5,2), substr($strDate,8,2), substr($strDate,11,2), substr($strDate,14,2), substr($strDate,17,2));
  40.                 // make the string representation of the date a timestamp
  41.                 $strDate = strtotime($strDate);
  42.                 // format the date if one exists and present it to user
  43.                 $strDate = date("M j, Y g:h A", $strDate);
  44.             }
  45.             else
  46.             {
  47.                 $strDate = NULL;
  48.             }
  49.             imgHeaderDataForDisplay("Taken", $strDate, NULL);
  50.             imgHeaderDataForDisplay("Size", bytesToHumanReadableUsage(imgHeaderData("FILE", "FileSize", $arImgHeaders),1), NULL);
  51.             imgHeaderDataForDisplay("Width", imgHeaderData("COMPUTED", "Width", $arImgHeaders), "pixels");
  52.             imgHeaderDataForDisplay("Height", imgHeaderData("COMPUTED", "Height", $arImgHeaders), "pixels");
  53.             imgHeaderDataForDisplay("Aperture", imgHeaderData("COMPUTED", "ApertureFNumber", $arImgHeaders), NULL);
  54.             imgHeaderDataForDisplay("Shutter Speed", imgHeaderData("EXIF", "ExposureTime", $arImgHeaders), "sec");
  55.             imgHeaderDataForDisplay("Focal Length", imgHeaderData("EXIF", "FocalLength", $arImgHeaders), NULL);
  56.             break;
  57.         default:
  58.             try
  59.             {
  60.                 $nmSharedPlace = $nmNetworkLib->OpenShare($sShare);
  61.                 if ($bIsDir)
  62.                 {
  63.                     imgHeaderDataForDisplay("Type", "Folder", NULL);
  64.                 }
  65.                 else
  66.                 {
  67.                     imgHeaderDataForDisplay("Type", $nmSharedPlace->GetFileTypeDescription($sPath), NULL);
  68.                     imgHeaderDataForDisplay("Size", bytesToHumanReadableUsage(filesize($sPath),1), NULL);
  69.                 }
  70.             }
  71.             catch(Exception $ex)
  72.             {
  73.                 log_activity("get details", "exception", $ex->getMessage());
  74.             }
  75.             $strDate = filemtime($sPath);
  76.             if ($strDate != "")
  77.             {
  78.                 // format the date if one exists and present it to user
  79.                 $strDate = date("M j, Y g:h A", $strDate);
  80.             }
  81.             else
  82.             {
  83.                 $strDate = NULL;
  84.             }
  85.             imgHeaderDataForDisplay("Date", $strDate, NULL);
  86.     }
  87.     ///////////////////////////////////////////////////
  88.     // Something funky, no details came back
  89.     ///////////////////////////////////////////////////
  90.     if ($iDetailsCount == 0)
  91.     {
  92.         echo ("No details are available for this file.");    
  93.     }
  94. ?>
  95.             </div>
  96.         </td>
  97.     </tr>
  98. </table>
  99. <?php
  100. ///////////////////////////////////////////////////
  101. // get the EXIF header data for later display/formatting
  102. // returns NULL if value does not eixst
  103. ///////////////////////////////////////////////////
  104. function imgHeaderData($sKey, $sName, $arImgHeaders)
  105. {
  106.     if (isset($arImgHeaders[$sKey][$sName]))
  107.     {
  108.         return $arImgHeaders[$sKey][$sName];
  109.     }
  110.     else
  111.     {
  112.         return NULL;
  113.     }
  114. }
  115. ///////////////////////////////////////////////////
  116. // display the formatted EXIF header data in divs
  117. // only prints if the value passed is NON NULL
  118. ///////////////////////////////////////////////////
  119. function imgHeaderDataForDisplay($sTitle, $sValue, $sTextLabel)
  120. {
  121.     global $iDetailsCount;
  122.     if (isset($sValue))
  123.     {
  124.         echo ("<div class=\"ExifHeaderData\"><span class=\"ExifHeaderTitle\">" . $sTitle . ": </span>");
  125.         echo ($sValue);
  126.         if ($sTextLabel != NULL)
  127.         {
  128.             echo (" " . $sTextLabel);
  129.         }
  130.         echo ("</div>");
  131.         echo ("<div class=\"ExifHR\"><img src=\"/images/pixel.trans.gif\" width=\"1\" height=\"1\" alt=\"\"/></div>");
  132.         $iDetailsCount++;
  133.     }
  134. }
  135. ?>